package com.example.campuslink.commen.db.userNumber

import androidx.room.TypeConverter
import com.example.campuslink.commen.db.comment.CommentTable
import com.example.campuslink.commen.db.invitation.InvitationTable
import com.example.campuslink.model.CommendInfoData
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken

class ListCommendInfoConverters {
    private val gson = Gson()
    private val listType = object : TypeToken<MutableList<CommendInfoData>>() {}.type

    @TypeConverter
    fun fromString(value: String): MutableList<CommendInfoData>? {
        return if (value.isBlank()) null else gson.fromJson(value, listType)
    }

    @TypeConverter
    fun fromList(list: MutableList<CommendInfoData>?): String {
        return gson.toJson(list ?: emptyList<CommendInfoData>())
    }
}